package converter;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import repository.UserRepository;
import domain.User;

@Component
public class UserConverter implements Converter<String, User>{
	
	private UserRepository userRepository;
	
	@Autowired
	public UserConverter(UserRepository userRepository) {
		this.userRepository = userRepository;
	}

	@Override
	public User convert(String source) {
		return userRepository.getUser(Integer.valueOf(source));
	}

}
